
// url   前端发送请求时携带的信息(请求的地址) =>  后端接收请求之后对url进行解析

let url = require("url");
// console.log(url);

// url.parse(str,bool) 将url字符串解析为对象
// str => 要解析的字符串
// bool  => 是否将query中的参数数据队列解析为对象 (默认false)
/* var str = "http://localhost:5050/day30/html/index.html?name=a123123&age=18#one";

var data = url.parse(str);
console.log(data);

var data = url.parse(str,true);
console.log(data);
console.log(data.query);
 */

var data = {
    protocol: 'http:',
    slashes: true,
    auth: null,
    host: 'localhost:5050',
    port: '5050',
    hostname: 'localhost',
    hash: '#one',
    search: '?name=a123123&age=18',
    query:  { name: 'a123123', age: '18' },
    pathname: '/day30/html/index.html',
    path: '/day30/html/index.html?name=a123123&age=18',
}

var str = url.format(data);
console.log(str);

